package resource;

import java.io.FileReader;
import java.util.HashMap;

import javax.xml.parsers.SAXParserFactory;

import org.newdawn.slick.Sound;
import org.xml.sax.InputSource;

import resource.handler.SoundHandler;

public class SoundManager {

	HashMap<String, Sound> l_s;
	public SoundManager(String file){
		l_s = new HashMap<String, Sound>();
		javax.xml.parsers.SAXParserFactory spf = SAXParserFactory.newInstance();
		spf.setValidating(false);
		javax.xml.parsers.SAXParser sp;
		try {
			sp = spf.newSAXParser();
			org.xml.sax.InputSource input = new InputSource(new FileReader(file));
			SoundHandler handler = new SoundHandler(l_s);
			sp.parse(input, handler);
		} catch (Exception e) {
			e.printStackTrace();
		};
	}
	
	public Sound getSound(String name){
		return  l_s.get(name);
	}
}
